#!/bin/bash

# Default values
skip_download=false
skip_deps=false
skip_spec=false

# Parse command line arguments
while [[ $# -gt 0 ]]; do
    case $1 in
        --skip-download)
            skip_download=true
            shift
            ;;
        --skip-deps)
            skip_deps=true
            shift
            ;;
        --skip-spec)
            skip_spec=true
            shift
            ;;
        --help)
            echo "Usage: $0 [options]"
            echo "Options:"
            echo "  --skip-download    Skip source code download phase"
            echo "  --skip-deps        Skip dependency generation phase"
            echo "  --skip-spec        Skip spec generation phase"
            echo "  --help             Show this help message"
            exit 0
            ;;
        *)
            echo "Unknown option: $1"
            echo "Use --help for usage information"
            exit 1
            ;;
    esac
done

if [ "$skip_download" = false ]; then
    echo "----start download source ----"
    bash get-src-from-ubuntu.sh
    echo "----end download source ----"
fi

if [ "$skip_deps" = false ]; then
    echo "----start generate depends from source ----"
    bash get-pkg-deps.sh
    echo "----end  generate depends from source----"
fi

if [ "$skip_spec" = false ]; then
    echo "----start  generate spec from source----"
    bash gen-pkg-spec.sh
    echo "----end   generate spec from source----"
fi
